package org.kirhgoff.mathbot;

import org.aicontest.Fleet;

public class FleetInfo {

	private int owner;
	private int size;
	private PlanetInfo sourcePlanet;
	private PlanetInfo destinationPlanet;
	private int totalTripLength;
	private final int turnsRemaining;

	public FleetInfo(int owner, int numShips, PlanetInfo sourcePlanet, PlanetInfo destinationPlanet, int totalTripLength, int turnsRemaining) {
		this.owner = owner;
		this.size = numShips;
		this.setSourcePlanet(sourcePlanet);
		this.destinationPlanet = destinationPlanet;
		this.totalTripLength = totalTripLength;
		this.turnsRemaining = turnsRemaining;
	}
	
	public FleetInfo(World world, Fleet fleet) {
		this (fleet.Owner(), fleet.NumShips(), 
				world.model (fleet.SourcePlanet()), 
				world.model (fleet.DestinationPlanet()), 
				fleet.TotalTripLength(), fleet.TurnsRemaining());
	}

	public Integer getRemainingTurns() {
		return turnsRemaining;
	}

	public int owner() {
		return owner;
	}

	public int size() {
		return size;
	}

	public PlanetInfo destinationPlanet() {
		return destinationPlanet;
	}
	
	@Override
	public String toString() {
		return "Fleet: owner=" + World.name(owner ()) + " size=" + size () + 
		" dest=" + destinationPlanet.id() + " dist=" + totalTripLength() + 
		" turns=" + turnsRemaining;
	}

	public boolean isMine() {
		return owner == World.OWNER_ME;
	}

	public void setSourcePlanet(PlanetInfo sourcePlanet) {
		this.sourcePlanet = sourcePlanet;
	}

	public PlanetInfo getSourcePlanet() {
		return sourcePlanet;
	}

	public void totalTripLength(int totalTripLength) {
		this.totalTripLength = totalTripLength;
	}

	public int totalTripLength() {
		return totalTripLength;
	}
}
